package com.leonzhangxf.ioc.container.extension;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.stereotype.Component;

/**
 * A hello world factory bean to produce a hello world object.
 *
 * @author leonzhangxf
 */
@Component("helloWorldObject")
public class HelloWorldObjectFactoryBean implements FactoryBean<HelloWorldObject> {

    /**
     * Usually used to create complex bean or process complicated bean creation.
     * There is just use demo. Not actually use with these kind simple.
     *
     * @return {@link HelloWorldObject}
     * @throws Exception Be thrown when create bean error.
     */
    @Override
    public HelloWorldObject getObject() throws Exception {
        return new HelloWorldObject();
    }

    @Override
    public Class<HelloWorldObject> getObjectType() {
        return HelloWorldObject.class;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }

    @Override
    public String toString() {
        return "HelloWorldObjectFactoryBean{}";
    }
}
